<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8"/>
        <meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no,maximum-scale=1.0,minimum-scale=1.0">
        <title>
        test2
        </title>
        <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js">
    
        </script>
        <!-- 引入 layui.css -->
    <link href="./css/layui.css" rel="stylesheet" />

    <!-- 引入 layui.js -->
    <script src="./js/layui.js"></script>
    <script src="./js/utils.js"></script>
    <script src="./js/constant.js" ></script>
    <script src="./js/data.js"></script>
    <script src="./js/userAuth.js"></script>
    <script src="./js/request.js"></script>
    <script type="text/javascript">    
        $(document).ready(()=>{
            // init();
            console.log('history len:',history.length);

            window.addEventListener("popstate",function(){
            alert("run popstate");
        })
        })
        function go(){
            console.log(history.length);
            // 原页面数据会丢失
            history.go(-1)
        }
        function back(){
            console.log(history.length);
            // 原页面数据会保留
            history.back(-1)
        }
    </script>
    </head>
    <body>
        <div onclick="go()">
            go(-1)
        </div>
        <div onclick="back()">
            back(-1)
        </div>
    </body>
</html>